﻿<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.01//EN' 'http://www.w3.org/tr/html4/strict.dtd'>
<html lang="zh-tw">
<head>
	<meta http-equiv='Content-Type' content='text/html; charset=utf-8' />
	<meta http-equiv='Content-Language' content='zh-tw' />
	<meta http-equiv='expires' content='-1' />
	<title>拆挽試算</title>
	<script type="text/javascript" src="/-common/js/utility.js" charset="utf-8"></script>
	<link rel="stylesheet" type="text/css" media="screen" href="/-common/images/jqueryui.lightness.min.css" />
	<style type="text/css">
	.AppendForm{ width: 80%; margin: 0px auto; padding: 0px;
		/* CSS3 */
		border-radius:         12px;
		-webkit-border-radius: 12px;
		-moz-border-radius:    12px;
		-o-border-radius:      12px;
		-khtml-border-radius:  12px;
	}
	</style>
</head>
<body style=" background: #ffff99;">
<form  name=AppendForm id=AppendForm method="post" class="AppendForm">
	<h2>一般備註</h2>
	<table border=0>
	<tr><td>DTV拆挽(優CATV裝機費)</td><td>
	<input type=text size=60 readonly name="txt1" value="數位化供裝併優惠裝機費；非數位化供裝需補收裝機費1,500元。"><input type=button value="全選" onclick="this.form.txt1.focus();this.form.txt1.select();">
	</td></tr>
	<tr><td>DTV同裝(裝機費-300)</td><td>
	<input type=text size=60 readonly name="txt2" value="新裝機客戶免費數位化供裝(未數位化供裝需收足裝機費1,500元且不提供保留本優惠)，併贈送三個月高畫質套餐頻道，三個月後未續訂僅提供有線電視頻道數位服務。"><input type=button value="全選" onclick="javascript:this.form.txt2.focus();this.form.txt2.select();">
	</td></tr>
	<tr><td>&nbsp;</td><td>&nbsp;</td></tr>
	<tr><td>DTA</td><td>
	<input type=text size=60 readonly name="txt21" value="數位化供裝併贈送三個月高畫質套餐頻道，三個月後未續訂僅提供有線電視頻道數位服務。"><input type=button value="全選" onclick="javascript:this.form.txt21.focus();this.form.txt21.select();">
	</td></tr>
	<tr><td>&nbsp;</td><td>&nbsp;</td></tr>
	<tr><td>60M$898三品1000元折裝機費</td><td>
	<input type=text size=60 readonly name="txt3" value="(郵政禮券2600元折抵裝機費1000)請收取總費用為1938元，並送客戶郵政禮券1600元。"><input type=button value="全選" onclick="this.form.txt3.focus();this.form.txt3.select();">
	</td></tr>
	<tr><td>60M$838三品1000元折裝機費</td><td>
	<input type=text size=60 readonly name="txt31" value="(郵政禮券2200元折抵裝機費1000)請收取總費用為1878元，並送客戶郵政禮券1200元。"><input type=button value="全選" onclick="this.form.txt31.focus();this.form.txt31.select();">
	</td></tr>
	</table>
	<hr size=1>
	<h2>拆挽三品備註</h2>
	<div>
		<label>申裝速率</label>
		<select name="Speed3" tabindex="1">
			<option value="24">24M</option>
			<option value="12">12M</option>
			<option value="6">6M</option>
		</select>
		搭配機上盒<select name="DTVprice3">
			<option value=''>無</option>
			<option value='84'>$84元</option>
			<option value='99'>$99元</option>
			<option value='104'>$104元</option>
			<option value='119'>$119元</option>
			<option value='168'>$168元</option>
			<option value='188'>$188元</option>
		</select>&nbsp;&nbsp;&nbsp;<input type="button" value="產生" onclick="CheckNote();" style="border-style: ridge; border-width: 1px; background-color: #800080; color:#FFFF00">
		<br />
		<textarea name=Note id=Note readonly style="height:35pt; width:400pt;"></textarea>
	</div>
	<hr size=1>
	<h6>拆挽試算</h6>
	<div>
		<label>申裝速率</label>
		<select name="Speed" tabindex="1">
			<option value="24">24M</option>
			<option value="12">12M</option>
		</select>
	</div>
	<div>
		<label>有線電視次收日</label>
		<select name="CatvDateYear">
			<option value="2013">2013</option>
			<option value="2014">2014</option>
		</select>年
		<select name="CatvDateMonth">
			<option value="1">1</option>
			<option value="2">2</option>
			<option value="3">3</option>
			<option value="4">4</option>
			<option value="5">5</option>
			<option value="6">6</option>
			<option value="7">7</option>
			<option value="8">8</option>
			<option value="9">9</option>
			<option value="10">10</option>
			<option value="12">12</option>
			<option value="12">12</option>
		</select>月
		<input name="CatvDateDay" size="1" maxlength="2" value="1">日<br />
		<label>寬頻預定裝機日</label>
		<select name="BBDateYear">
			<option value="2013">2013</option>
		</select>年
		<select name="BBDateMonth">
			<option value="1">1</option>
			<option value="2">2</option>
			<option value="3">3</option>
			<option value="4">4</option>
			<option value="5">5</option>
			<option value="6">6</option>
			<option value="7">7</option>
			<option value="8">8</option>
			<option value="9">9</option>
			<option value="10">10</option>
			<option value="12">12</option>
			<option value="12">12</option>
		</select>月
		<input name="BBDateDay" size="1" maxlength=2>日
	</div>
	<div>
		搭配機上盒<select name="DTVprice">
			<option value=''>無</option>
			<option value='84'>$84元</option>
			<option value='99'>$99元</option>
			<option value='104'>$104元</option>
			<option value='119'>$119元</option>
			<option value='168'>$168元</option>
			<option value='188'>$188元</option>
		</select>&nbsp;&nbsp;&nbsp;<input type="button" value="試算" onclick="CheckAppend();" style="border-style: ridge; border-width: 1px; background-color: #800080; color:#FFFF00">
	</div>
	<hr size=1>
	收費期間：<input type=text size=8 name=Date1 readonly>&nbsp;&nbsp;
	次收日期：<input type=text size=8 name=Date2 readonly>&nbsp;&nbsp;
	寬頻應收金額：<input type=text size=3 name=Amount id=Amount readonly>元&nbsp;&nbsp;
	機上盒應收金額：<input type=text size=3 name=AmountDTV id=AmountDTV readonly>元<br />
	<textarea name=Desc id=Desc readonly style="height:70pt; width:400pt;"></textarea>
</form>
</body>
</html>
<script type='text/javascript' src='http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js'></script>
<script type='text/javascript' src='http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/jquery-ui.min.js'></script>
<script type='text/javascript'>
var f = document.AppendForm;
/*
$(function() {
	$.datepicker.setDefaults({
		firstDay: 1,
		dayNamesMin: ['日', '一', '二', '三', '四', '五', '六'],
		monthNames: ['一月','二月','三月','四月','五月','六月','七月','八月','九月','十月','十一月','十二月'],
		duration: 'fast'
	});
	$('#CatvDate').datepicker();
	$('#BBDate').datepicker();
});
*/
function CheckNote() {
	switch(f.Speed3.value) {
		case '24':
			var Price3 = 1099;
			break;
		case '12':
			var Price3 = 999;
			break;
		case '6':
			var Price3 = 739;
			break;
	}
	if (f.DTVprice3.value!='') {Price3 = Price3 + parseInt(f.DTVprice3.value, 10)}

	var Note = "本方案為有線電視+"+f.Speed3.value+"M";
	if (f.DTVprice3.value!='') {Note = Note + "+數位電視服務";}		
	Note = Note + "每月優惠價"+Price3+"元，若取消任一服務即恢復原價";
	f.Note.value = Note;

}
function CheckAppend() {
	if (f.CatvDateDay.value=='') {
		alert('請輸入有線電視次收日期');
		f.CatvDateDay.focus();
		return false;
	}
	if (f.BBDateDay.value=='') {
		alert('請輸入寬頻預定裝機日期');
		f.BBDateDay.focus();
		return false;
	}

	var CatvPriceOld = 540; /*有線電視原始月費*/
	switch(f.Speed.value) {
		case '24':
			var CatvPriceNew = 424; /*有線電視新的拆帳月費(24M)*/
			var BBPriceOld = 559; /*24M拆挽舊月費*/
			var BBPriceNew = 675; /*24M拆挽新月費*/
			break;
		case '12':
			var CatvPriceNew = 425; /*有線電視新的拆帳月費(12M)*/
			var BBPriceOld = 459; /*12M拆挽舊月費*/
			var BBPriceNew = 574; /*12M拆挽新月費*/
			break;
	}
	var CatvDateX = f.CatvDateYear.value+"/"+f.CatvDateMonth.value+"/"+f.CatvDateDay.value;
	var CatvDate = new Date(CatvDateX);
	var BBDateX = f.BBDateYear.value+"/"+f.BBDateMonth.value+"/"+f.BBDateDay.value;
	var BBDate = new Date(BBDateX);
	var DiffMonth = CatvDate.getMonth() - BBDate.getMonth();
	var DiffDay = BBDate.getDate() - 1;
	var Balance = CatvPriceOld * DiffMonth - (CatvPriceOld/30) * DiffDay;
	if (Balance < CatvPriceNew) {
		alert('有線電視未到期費用不足以展延為一個月以上，本件請送客服/助理派工後再向客戶報費用。');
		return false;
	}
	var Xday =  Math.round((Balance-(CatvPriceNew*DiffMonth-(CatvPriceNew/30)*DiffDay))/(CatvPriceNew/30));
	/* =========================== */
	var Date1Month = CatvDate.getMonth()+1;
	var Date1Day = CatvDate.getDate()+Xday-1;
	var Date1Year = CatvDate.getFullYear();
	switch(Date1Month) {
		case 1:
		case 3:
		case 5:
		case 7:
		case 8:
		case 10:
		case 12:
			var CheckMonth1 = 31;
			break;
		case 4:
		case 6:
		case 9:
		case 11:
			var CheckMonth1 = 30;
			break;
		case 2:
			var CheckMonth1 = 28;
			break;
		
	}
	if (Date1Day > CheckMonth1) {
		Date1Month = Date1Month+1;
		Date1Day = Date1Day-CheckMonth1;
	}
	var Date1 = Date1Year + "/" + Date1Month + "/" + Date1Day;
	f.Date1.value = Date1;
	/* =========================== */
	var Date2Month = CatvDate.getMonth()+1;
	var Date2Day = CatvDate.getDate()+Xday;
	var Date2Year = CatvDate.getFullYear();
	switch(Date2Month) {
		case 1:
		case 3:
		case 5:
		case 7:
		case 8:
		case 10:
		case 12:
			var CheckMonth2 = 31;
			break;
		case 4:
		case 6:
		case 9:
		case 11:
			var CheckMonth2 = 30;
			break;
		case 2:
			var CheckMonth2 = 28;
			break;
		
	}
	if (Date2Day > CheckMonth2) {
		Date2Month = Date2Month+1;
		Date2Day = Date2Day-CheckMonth2;
	}
	var Date2 = Date2Year + "/" + Date2Month + "/" + Date2Day;
	f.Date2.value = Date2;
	/* =========================== */
	var Amount = Math.round(BBPriceNew * DiffMonth + (Xday-DiffDay) * (BBPriceNew/30));
	f.Amount.value = Amount;
	if (f.DTVprice.value!='') {
		var DTVprice = parseInt(f.DTVprice.value,10);
		var AmountDTV = Math.round(DTVprice * DiffMonth + (Xday-DiffDay) * (DTVprice/30));
		f.AmountDTV.value = AmountDTV;
		Amount = Amount + AmountDTV;
	}
	/* =========================== */
	var Price = CatvPriceOld+BBPriceOld;
	if (f.DTVprice.value!='') {
		Price = Price+DTVprice;
	}	
	var All = Math.round(Price * DiffMonth + (Xday-DiffDay) * (Price/30));
	var Desc = "本方案為有線電視+"+f.Speed.value+"M";
	if (f.DTVprice.value!='') {Desc = Desc + "+數位電視服務";}		
	Desc = Desc + "優惠價"+Price+"元，本次收費期間為"+BBDateX+"至"+Date1+"；應收費用為"+All+"元，因有線電視已預繳"+Balance+"元，本次收費金額為"+Amount+"元；下期有線電視+"+f.Speed.value+"M";
	if (f.DTVprice.value!='') {Desc = Desc + "+數位電視服務";}		
	Desc = Desc + "帳單將自"+Date2+"開始收費。";
	f.Desc.value = Desc;
}
</script>